import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
import actionscript from 'highlight.js/lib/languages/actionscript'

/**
 * Note: 路由配置项
 *
 * hidden: true                     // 当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1
 * alwaysShow: true                 // 当你一个路由下面的 children 声明的路由大于1个时，自动会变成嵌套的模式--如组件页面
 *                                  // 只有一个时，会将那个子路由当做根路由显示在侧边栏--如引导页面
 *                                  // 若你想不管路由下面的 children 声明的个数都显示你的根路由
 *                                  // 你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由
 * redirect: noRedirect             // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
 * name:'router-name'               // 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题
 * query: '{"id": 1, "name": "ry"}' // 访问路由的默认传递参数
 * roles: ['admin', 'common']       // 访问路由的角色权限
 * permissions: ['a:a:a', 'b:b:b']  // 访问路由的菜单权限
 * meta : {
    noCache: true                   // 如果设置为true，则不会被 <keep-alive> 缓存(默认 false)
    title: 'title'                  // 设置该路由在侧边栏和面包屑中展示的名字
    icon: 'svg-name'                // 设置该路由的图标，对应路径src/assets/icons/svg
    breadcrumb: false               // 如果设置为false，则不会在breadcrumb面包屑中显示
    activeMenu: '/system/user'      // 当路由设置了该属性，则会高亮相对应的侧边栏。
  }
 */

// 公共路由
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login'),
    hidden: true
  },
  {
    path: '/register',
    component: () => import('@/views/register'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error/401'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/dashboard/index'),
        name: 'Index',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/ai',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        component: () => import('@/views/ai/index'),
        name: 'AiChat',
        meta: { title: 'AI助手', icon: 'robot' }
      }
    ]
  },
  {
    path: '/sc',
    component: Layout,
    redirect: 'noRedirect',
    alwaysShow: true,
    meta: {
      title: '生产管理',
      icon: 'build'
    },
    children: [
      {
        path: 'order',
        component: () => import('@/views/sc/order/sc_order'),
        name: 'ScOrder',
        meta: { title: '生产订单', icon: 'list' }
      },
      {
        path: 'order/add',
        component: () => import('@/views/sc/order/AddOrder'),
        name: 'AddOrder',
        hidden: true,
        meta: { title: '新增生产订单', activeMenu: '/sc/order' }
      },
      {
        path: 'order/edit',
        component: () => import('@/views/sc/order/EditOrder'),
        name: 'EditOrder',
        hidden: true,
        meta: { title: '编辑生产订单', activeMenu: '/sc/order' }
      },
      {
        path: 'order/detail',
        component: () => import('@/views/sc/order/OrderDetail'),
        name: 'OrderDetail',
        hidden: true,
        meta: { title: '生产订单详情', activeMenu: '/sc/order' }
      },
      {
        path: 'plan',
        component: () => import('@/views/sc/plan/sc_plan'),
        name: 'ScPlan',
        meta: { title: '生产计划', icon: 'list' }
      },
      {
        path: 'plan/add',
        component: () => import('@/views/sc/plan/add_plan'),
        name: 'AddPlan',
        hidden: true,
        meta: { title: '新增生产计划', activeMenu: '/sc/plan' }
      },
      {
        path: 'plan/edit',
        component: () => import('@/views/sc/plan/edit_plan'),
        name: 'EditPlan',
        hidden: true,
        meta: { title: '编辑生产计划', activeMenu: '/sc/plan' }
      },
      {
        path: 'plan/detail',
        component: () => import('@/views/sc/plan/detail_plan'),
        name: 'DetailPlan',
        hidden: true,
        meta: { title: '生产计划详情', activeMenu: '/sc/plan' }
      },
      {
        path: 'work',
        component: () => import('@/views/sc/work/sc_work'),
        name: 'ScWork',
        meta: { title: '生产工单', icon: 'list' }
      },
      {
        path: 'work/detail',
        component: () => import('@/views/sc/work/detail'),
        name: 'WorkDetail',
        hidden: true,
        meta: { title: '工单详情', activeMenu: '/sc/work' }
      },
      {
        path: 'work/scheduling',
        component: () => import('@/views/sc/work/scheduling'),
        name: 'WorkScheduling',
        hidden: true,
        meta: { title: '工单排产', activeMenu: '/sc/work' }
      },
      {
        path: 'task',
        component: () => import('@/views/sc/task/sc_task'),
        name: 'ScTask',
        meta: { title: '生产任务', icon: 'list' }
      },
      {
        path: 'task/detail/:id',
        component: () => import('@/views/sc/task/detail'),
        name: 'TaskDetail',
        hidden: true,
        meta: { title: '生产任务详情', activeMenu: '/sc/task' }
      },
      {
        path: 'Signning',
        component: () => import('@/views/sc/report/index'),
        name: 'ScSignning',
        meta: { title: '生产报工', icon: 'form' }
      },
      {
        path: '/sc/task/dispatch',
        component: () => import('@/views/sc/task/create'),
        name: 'DispatchTask',
        meta: { title: '工单派工', activeMenu: '/sc/task' },
        hidden: true
      },
      {
        path: 'process',
        component: () => import('@/views/sc/process/sc_process'),
        name: 'ScProcess',
        meta: { title: '工序管理', icon: 'list' }
      },
      {
        path: 'operational',
        component: () => import('@/views/sc/operational/sc_operational'),
        name: 'ScOperational',
        meta: { title: '工艺路线', icon: 'list' }
      },
      {
        path: 'process/route-detail/:id',
        component: () => import('@/views/sc/process/process_route_detail'),
        name: 'ProcessRouteDetail',
        hidden: true,
        meta: { title: '工艺路线详情', activeMenu: '/sc/operational' }
      }
    ]
  },
  /*{
    path: '/report',
    component: Layout,
    redirect: 'noRedirect',
    alwaysShow: true,
    name: 'ReportManagement',
    meta: {
      title: '报表管理',
      icon: 'chart'
    },
    children: [
      {
        path: 'list',
        component: () => import('@/views/report/list/index'),
        name: 'ReportList',
        meta: { title: '报表清单', icon: 'list' }
      },
      {
        path: 'design',
        component: () => import('@/views/report/design/index'),
        name: 'ReportDesign',
        meta: { title: '报表设计', icon: 'edit' }
      },
      {
        path: 'design/add',
        component: () => import('@/views/report/design/add'),
        name: 'ReportAdd',
        hidden: true,
        meta: { title: '新增报表', activeMenu: '/report/list' }
      },
      {
        path: 'design/edit/:id',
        component: () => import('@/views/report/design/edit'),
        name: 'ReportEdit',
        hidden: true,
        meta: { title: '编辑报表', activeMenu: '/report/list' }
      },
      {
        path: 'view/:id',
        component: () => import('@/views/report/list/view'),
        name: 'ReportView',
        hidden: true,
        meta: { title: '报表查看', activeMenu: '/report/list' }
      }
    ]
  },*/
  {
    path: '/qc',
    component: Layout,
    name: 'Quality',
    meta: { title: '质量管理', icon: 'list' }, // 你可以换成自定义的icon
    children: [
      {
        path: 'ZlCommonDefects',
        component: () => import('@/views/qc/CommonDefects/index'),
        name: 'CommonDefects',
        meta: { title: '常见缺陷', icon: 'list' } // 使用错误图标表示缺陷
      },
      {
        path: 'ZlDetectionItemSettings',
        component: () => import('@/views/qc/DetectionItemSettings/index'),
        name: 'DetectionItemSettings',
        meta: { title: '检测项设置', icon: 'list' } // 使用设置图标
      },
      {
        path: 'QualityScheme',
        component: () => import('@/views/qc/QualityScheme/index'),
        name: 'ZlQualityScheme',
        meta: { title: '质检方案', icon: 'list' } // 使用策略或计划图标
      },
      {
        path: 'PendingTasks',
        component: () => import('@/views/qc/PendingTasks/index'),
        name: 'ZlPendingTasks',
        meta: { title: '待检任务', icon: 'list' } // 使用待办事项图标
      },
      {
        path: 'IncomingInspection',
        component: (resolve) => require(['@/views/qc/IncomingInspection/index'], resolve),
        name: 'IncomingInspection',
        meta: { title: '来料检验', icon: 'tool' }
      },
      {
        path: 'IqcDetail/:code',
        component: (resolve) => require(['@/views/qc/IncomingInspection/IqcDetail'], resolve),
        name: 'IqcDetail',
        meta: { title: '检验单详情', activeMenu: '/qc/IncomingInspection' },
        hidden: true
      },
      {
        path: 'IncomingInspection/detail/:id',
        component: () => import('@/views/qc/IncomingInspection/IqcDetail'),
        name: 'IncomingInspectionDetail',
        meta: { title: '来料检验单详情', activeMenu: '/qc/IncomingInspection' },
        hidden: true
      },
      {
        path: 'OutgoingInspection',
        component: () => import('@/views/qc/OutgoingInspection/index'),
        name: 'ZlOutgoingInspection',
        meta: { title: '出货检验', icon: 'tool' } // 使用出货图标
      },
      {
        path: 'OutgoingInspection/detail/:id',
        component: () => import('@/views/qc/OutgoingInspection/detail'),
        name: 'OutgoingInspectionDetail',
        meta: { title: '出货检验单详情', activeMenu: '/qc/OutgoingInspection' },
        hidden: true
      },

      {
        path: 'ProcesInspection',
        component: () => import('@/views/qc/ProcesInspection/index'),
        name: 'ZlProcesInspection',
        meta: { title: '过程检验', icon: 'tool' } // 使用流程图标
      },
      {
        path: 'ProcesInspection/detail/:id',
        component: () => import('@/views/qc/ProcesInspection/IpqcDetail'),
        name: 'IpqcDetail',
        meta: { title: '过程检验单详情', activeMenu: '/qc/ProcesInspection' },
        hidden: true
      },

      {
        path: 'ReturnInspection',
        component: () => import('@/views/qc/ReturnInspection/index'),
        name: 'ZlReturnInspection',
        meta: { title: '退料检验', icon: 'tool' } // 使用出货图标
      },
      {
        path: 'ReturnInspection/detail/:id',
        component: () => import('@/views/qc/ReturnInspection/detail'),
        name: 'ReturnInspectionDetail',
        meta: { title: '退料检验单详情', activeMenu: '/qc/ReturnInspection' },
        hidden: true
      },
      {
        path: 'LotTraceability',
        component: () => import('@/views/qc/LotTraceability/index'),
        name: 'ZlLotTraceability',
        meta: { title: '质检溯源', icon: 'tool' } // 使用历史图标
      },
      {
        path: 'LotTraceability/detail',
        component: () => import('@/views/qc/LotTraceability/detail'),
        name: 'LotTraceabilityDetail',
        meta: { title: '质检溯源详情', activeMenu: '/qc/LotTraceability' },
        hidden: true
      },


    ]
  },
  {
    path: '/ck',
    component: Layout,
    redirect: 'Warehouse',
    alwaysShow: true,
    meta: {
      title: '仓储管理',
      icon: 'zip'
    },
    children: [
      {
        path: 'setup',
        component: () => import('@/views/ck/setup/ck_List.vue'),
        name: 'ckSetup',
        meta: { title: '仓库设置', icon: 'dict' }
      },
      {
        path: 'setup/add',
        component: () => import('@/views/ck/test/ck_test'),
        name: 'addSetup',
        hidden: true,
        meta: { title: '新增仓库', activeMenu: '' }
      },
      {
        path: 'setup/Area',
        component: () => import('@/views/ck/setup/ck_Area'),
        name: 'Area',
        hidden: true,
        meta: { title: '库区', activeMenu: '' }
      },
      {
        path: 'setup/Location',
        component: () => import('@/views/ck/setup/ck_Location'),
        name: 'Location',
        hidden: true,
        meta: { title: '库位', activeMenu: '' }
      },
      {
        path: 'inventory',
        component: () => import('@/views/ck/inventory/ck_Management.vue'),
        name: 'ckInventory',
        meta: { title: '库存现有量', icon: 'chart' }
      },
      {
        path: 'PurchaseOrder',
        component: () => import('@/views/ck/purchase/purchase_order'),
        name: 'ckPurchaseOrder',
        meta: { title: '采购订单', icon: 'list' }
      },
      {
        path: 'PurchaseOrder/addOrder',
        component: () => import('@/views/ck/purchase/add_purchase_order'),
        name: 'addOrder',
        hidden: true,
        meta: { title: '新增采购订单', activeMenu: '' }
      },
      {
        path: 'PurchaseOrder/updateOrder',
        component: () => import('@/views/ck/purchase/add_purchase_order'),
        name: 'updateOrder',
        hidden: true,
        meta: { title: '修改采购订单', activeMenu: '' }
      },
      {
        path: 'ArrivalNotice',
        component: () => import('@/views/ck/purchase/arrival_notice'),
        name: 'ckArrivalNotice',
        meta: { title: '到货通知', icon: 'wechat' }
      },
      {
        path: 'PurchaseInventory',
        component: () => import('@/views/ck/purchase/item_receipt'),
        name: 'ckPurchaseInventory',
        meta: { title: '采购入库', icon: 'form', storage_type: '1' }
      },
      {
        path: 'PurchaseInventory/addReceipt',
        component: () => import('@/views/ck/purchase/add_item_receipt'),
        name: 'addReceipt',
        hidden: true,
        meta: { title: '新增采购入库单', activeMenu: '' }
      },
      {
        path: 'PurchaseInventory/updateReceipt',
        component: () => import('@/views/ck/purchase/add_item_receipt'),
        name: 'updateReceipt',
        hidden: true,
        meta: { title: '修改采购入库单', activeMenu: '' }
      },
      /* {
        path: 'PurchaseReturn',
        component: () => import('@/views/ck/test/ck_test'),
        name: 'ckPurchaseReturn',
        meta: { title: '采购退货', icon: 'link' }
      },
      {
        path: 'Picking',
        component: () => import('@/views/ck/test/ck_test'),
        name: 'ckPicking',
        meta: { title: '生产领料', icon: 'edit' }
      }, */
      {
        path: 'MaterialReturn',
        component: () => import('@/views/ck/purchase/item_receipt'),
        name: 'ckMaterialReturn',
        meta: { title: '生产退料', icon: 'logininfor', storage_type: '2' }
      },
      {
        path: 'ProductStorage',
        component: () => import('@/views/ck/purchase/item_receipt'),
        name: 'ckProductStorage',
        meta: { title: '产品入库', icon: 'shopping', storage_type: '3' }
      },
      /* {
        path: 'DeliveryNotice',
        component: () => import('@/views/ck/test/ck_test'),
        name: 'ckDeliveryNotice',
        meta: { title: '发货通知单', icon: 'wechat' }
      }, */
      {
        path: 'SalesOutbound',
        component: () => import('@/views/ck/material/outbound'),
        name: 'ckSalesOutbound',
        meta: { title: '销售出库', icon: 'guide' }
      },
      {
        path: 'SalesOutbound/add',
        component: () => import('@/views/ck/material/add_outbound'),
        name: 'AddSalesOutbound',
        hidden: true,
        meta: { title: '新增销售出库单', activeMenu: '/ck/SalesOutbound' }
      },
      {
        path: 'SalesOutbound/update',
        component: () => import('@/views/ck/material/add_outbound'),
        name: 'UpdateSalesOutbound',
        hidden: true,
        meta: { title: '修改销售出库单', activeMenu: '/ck/SalesOutbound' }
      },
      /* {
        path: 'SalesReturns',
        component: () => import('@/views/ck/material/return'),
        name: 'ckSalesReturns',
        meta: { title: '销售退货', icon: 'link' }
      }, */
      /* {
        path: 'Transfer',
        component: () => import('@/views/ck/test/ck_test'),
        name: 'ckTransfer',
        meta: { title: '转移调拨', icon: 'swagger' }
      }, */
      {
        path: 'Stocktaking',
        component: () => import('@/views/inventory/check/index'),
        name: 'ckStocktaking',
        meta: { title: '库存盘点', icon: 'list' }
      },
      {
        path: 'Stocktaking/add',
        component: () => import('@/views/inventory/check/add'),
        name: 'AddStocktaking',
        hidden: true,
        meta: { title: '新增盘点', activeMenu: '/ck/Stocktaking' }
      },
      {
        path: 'Stocktaking/detail/:id',
        component: () => import('@/views/inventory/check/detail'),
        name: 'StocktakingDetail',
        hidden: true,
        meta: { title: '盘点详情', activeMenu: '/ck/Stocktaking' }
      }/* ,
      {
        path: 'Packing',
        component: () => import('@/views/ck/test/ck_test'),
        name: 'ckPacking',
        meta: { title: '装箱管理', icon: 'list' }
      },
      {
        path: 'Coding',
        component: () => import('@/views/ck/test/ck_test'),
        name: 'ckCoding',
        meta: { title: '赋码管理', icon: 'list' }
      },
      {
        path: 'SN_code',
        component: () => import('@/views/ck/test/ck_test'),
        name: 'ckSN_code',
        meta: { title: 'SN码', icon: 'list' }
      } */
    ]
  },
  {
    path: '/sb',
    component: Layout,
    redirect: 'Equipment',
    alwaysShow: true,
    meta: {
      title: '设备管理',
      icon: 'client'
    },
    children: [
      {
        path: 'equipment-types',
        component: () => import('@/views/sb/equipment-types/index'),
        name: 'equipment-types',
        meta: { title: '设备类型', icon: 'list' }
      },
      {
        path: 'equipment-ledger',
        component: () => import('@/views/sb/equipment-ledger/index'),
        name: 'equipment-ledger',
        meta: { title: '设备台账', icon: 'list' }
      },
      {
        path: 'equipment-ledger/add',
        component: () => import('@/views/sb/equipment-ledger/add'),
        name: 'EquipmentLedgerAdd',
        hidden: true,
        meta: { title: '新增设备', activeMenu: '/sb/equipment-ledger' }
      },
      {
        path: 'equipment-ledger/detail/:id',
        component: () => import('@/views/sb/equipment-ledger/detail'),
        name: 'EquipmentLedgerDetail',
        hidden: true,
        meta: { title: '设备详情', activeMenu: '/sb/equipment-ledger' }
      },
      {
        path: 'repair-application',
        component: () => import('@/views/sb/repair-application/index'),
        name: 'RepairApplication',
        meta: { title: '报修单', icon: 'list' }
      },
      {
        path: 'repair-application/add',
        component: () => import('@/views/sb/repair-application/add'),
        name: 'RepairApplicationAdd',
        hidden: true,
        meta: { title: '新增报修单', activeMenu: '/sb/repair-application' }
      },
      {
        path: 'repair-application/detail',
        component: () => import('@/views/sb/repair-application/detail'),
        name: 'RepairApplicationDetail',
        hidden: true,
        meta: { title: '报修单详情', activeMenu: '/sb/repair-application' }
      },
      {
        path: 'repair-order',
        component: () => import('@/views/sb/repair-order/index'),
        name: 'RepairOrder',
        meta: { title: '维修单', icon: 'list' }
      },
      {
        path: 'repair-order/detail',
        component: () => import('@/views/sb/repair-order/detail'),
        name: 'RepairOrderDetail',
        hidden: true,
        meta: { title: '维修单详情', activeMenu: '/sb/repair-order' }
      },
      {
        path: 'Inspection-plan',
        component: () => import('@/views/sb/inspection-plan/index'),
        name: 'InspectionPlan',
        meta: { title: '巡检计划', icon: 'list' }
      },
      {
        path: 'Inspection-plan/add',
        component: () => import('@/views/sb/inspection-plan/add'),
        name: 'AddInspectionPlan',
        hidden: true,
        meta: { title: '新增巡检计划', activeMenu: '/sb/Inspection-plan' }
      },
      {
        path: 'Inspection-plan/detail/:id',
        component: () => import('@/views/sb/inspection-plan/detail'),
        name: 'InspectionPlanDetail',
        hidden: true,
        meta: { title: '巡检计划详情', activeMenu: '/sb/Inspection-plan' }
      },
      {
        path: 'Inspection-list',
        component: () => import('@/views/sb/inspection-record/index'),
        name: 'InspectionRecord',
        meta: { title: '巡检单', icon: 'list' }
      },
      {
        path: 'Inspection-list/add',
        component: () => import('@/views/sb/inspection-record/add'),
        name: 'AddInspectionRecord',
        hidden: true,
        meta: { title: '新增巡检单', activeMenu: '/sb/Inspection-list' }
      },
      {
        path: 'Inspection-list/detail/:id',
        component: () => import('@/views/sb/inspection-record/detail'),
        name: 'InspectionRecordDetail',
        hidden: true,
        meta: { title: '巡检单详情', activeMenu: '/sb/Inspection-list' }
      },
      {
        path: 'Inspection-list/execute/:id',
        component: () => import('@/views/sb/inspection-record/execute'),
        name: 'ExecuteInspection',
        hidden: true,
        meta: { title: '执行巡检', activeMenu: '/sb/Inspection-list' }
      },
      {
        path: 'Patrol-configuration',
        component: () => import('@/views/sb/inspection-config/index'),
        name: 'InspectionConfig',
        meta: { title: '巡检配置', icon: 'list' }
      },
      {
        path: 'Patrol-configuration/add',
        component: () => import('@/views/sb/inspection-config/add'),
        name: 'AddInspectionConfig',
        hidden: true,
        meta: { title: '新增巡检项', activeMenu: '/sb/Patrol-configuration' }
      }/*,
      {
        path: 'Maintenance-plan',
        component: () => import('@/views/sb/maintenance-plan/index'),
        name: 'MaintenancePlan',
        meta: { title: '保养计划', icon: 'list' }
      },
      {
        path: 'Maintenance-plan/add',
        component: () => import('@/views/sb/maintenance-plan/add'),
        name: 'AddMaintenancePlan',
        hidden: true,
        meta: { title: '新增保养计划', activeMenu: '/sb/Maintenance-plan' }
      },
      {
        path: 'Maintenance-plan/detail/:id',
        component: () => import('@/views/sb/maintenance-plan/detail'),
        name: 'MaintenancePlanDetail',
        hidden: true,
        meta: { title: '保养计划详情', activeMenu: '/sb/Maintenance-plan' }
      },
      {
        path: 'Maintenance-sheet',
        component: () => import('@/views/sb/maintenance-record/index'),
        name: 'MaintenanceRecord',
        meta: { title: '保养单', icon: 'list' }
      },
      {
        path: 'Maintenance-sheet/add',
        component: () => import('@/views/sb/maintenance-record/add'),
        name: 'AddMaintenanceRecord',
        hidden: true,
        meta: { title: '新增保养单', activeMenu: '/sb/Maintenance-sheet' }
      },
      {
        path: 'Maintenance-sheet/detail/:id',
        component: () => import('@/views/sb/maintenance-record/detail'),
        name: 'MaintenanceRecordDetail',
        hidden: true,
        meta: { title: '保养单详情', activeMenu: '/sb/Maintenance-sheet' }
      },
      {
        path: 'Maintenance-configuration',
        component: () => import('@/views/sb/maintenance-config/index'),
        name: 'MaintenanceConfig',
        meta: { title: '保养配置', icon: 'list' }
      },
      {
        path: 'Maintenance-configuration/add',
        component: () => import('@/views/sb/maintenance-config/add'),
        name: 'AddMaintenanceConfig',
        hidden: true,
        meta: { title: '新增保养项', activeMenu: '/sb/Maintenance-configuration' }
      }*/
    ]
  },
  {
    path: '/basic',
    component: Layout,
    redirect: 'noRedirect',
    alwaysShow: true,
    meta: {
      title: '主数据',
      icon: 'documentation'
    },
    children: [
      {
        path: 'index',
        component: () => import('@/views/basic/wl/basic_wlfl.vue'),
        name: 'MasterDataIndex',
        meta: { title: '分类管理', icon: 'list' }
      },
      {
        path: 'material',
        component: () => import('@/views/basic/wl/basic_wl.vue'),
        name: 'basicMaterial',
        meta: { title: '物料管理', icon: 'list' }
      },

      {
        path: 'units',
        component: () => import('@/views/basic/wl/basic_units.vue'),
        name: 'basicUnits',
        meta: { title: '计量单位', icon: 'list' }
      },

      {
        path: 'customers',
        component: () => import('@/views/basic/wl/basic_customers.vue'),
        name: 'basicCustomers',
        meta: { title: '客户管理', icon: 'list' }
      },

      {
        path: 'supplier',
        component: () => import('@/views/basic/wl/basic_suppliers.vue'),
        name: 'basicSupplier',
        meta: { title: '供应商管理', icon: 'list' }
      },

      {
        path: 'products',
        component: () => import('@/views/basic/wl/basic_products.vue'),
        name: 'basicProduct',
        meta: { title: '产品管理', icon: 'list' }
      },

      {
        path: 'factoryModeling',
        component: () => import('@/views/basic/wl/basic_factoryModeling.vue'),
        name: 'basicfactoryModeling',
        meta: { title: '工厂建模', icon: 'list' }
      },

      {
        path: 'bom',
        component: () => import('@/views/basic/wl/basic_bom.vue'),
        name: 'basicBom',
        meta: { title: 'BOM管理', icon: 'list' }
      },

      {
        path: 'bomDetail',
        component: () => import('@/views/basic/wl/basic_bomDetaildata.vue'),
        name: 'basicBomDetail',
        hidden: true,
        meta: { title: 'BOM详情', activeMenu: '/basic/bom' }
      },

      {
        path: 'team',
        component: () => import('@/views/basic/wl/basic_team.vue'),
        name: 'basicTeam',
        meta: { title: '生产班组', icon: 'list' }
      },


    ]
  },
  {
    path: '/user',
    component: Layout,
    hidden: true,
    redirect: 'noredirect',
    children: [
      {
        path: 'profile',
        component: () => import('@/views/system/user/profile/index'),
        name: 'Profile',
        meta: { title: '个人中心', icon: 'user' }
      }
    ]
  }
]

// 动态路由，基于用户权限动态去加载
export const dynamicRoutes = [
  {
    path: '/system/user-auth',
    component: Layout,
    hidden: true,
    permissions: ['system:user:edit'],
    children: [
      {
        path: 'role/:userId(\\d+)',
        component: () => import('@/views/system/user/authRole'),
        name: 'AuthRole',
        meta: { title: '分配角色', activeMenu: '/system/user' }
      }
    ]
  },
  {
    path: '/system/role-auth',
    component: Layout,
    hidden: true,
    permissions: ['system:role:edit'],
    children: [
      {
        path: 'user/:roleId(\\d+)',
        component: () => import('@/views/system/role/authUser'),
        name: 'AuthUser',
        meta: { title: '分配用户', activeMenu: '/system/role' }
      }
    ]
  },
  {
    path: '/system/dict-data',
    component: Layout,
    hidden: true,
    permissions: ['system:dict:list'],
    children: [
      {
        path: 'index/:dictId(\\d+)',
        component: () => import('@/views/system/dict/data'),
        name: 'Data',
        meta: { title: '字典数据', activeMenu: '/system/dict' }
      }
    ]
  },
  {
    path: '/monitor/job-log',
    component: Layout,
    hidden: true,
    permissions: ['monitor:job:list'],
    children: [
      {
        path: 'index/:jobId(\\d+)',
        component: () => import('@/views/monitor/job/log'),
        name: 'JobLog',
        meta: { title: '调度日志', activeMenu: '/monitor/job' }
      }
    ]
  },
  {
    path: '/tool/gen-edit',
    component: Layout,
    hidden: true,
    permissions: ['tool:gen:edit'],
    children: [
      {
        path: 'index/:tableId(\\d+)',
        component: () => import('@/views/tool/gen/editTable'),
        name: 'GenEdit',
        meta: { title: '修改生成配置', activeMenu: '/tool/gen' }
      }
    ]
  }
]

// 防止连续点击多次路由报错
let routerPush = Router.prototype.push
let routerReplace = Router.prototype.replace
// push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(err => err)
}
// replace
Router.prototype.replace = function push(location) {
  return routerReplace.call(this, location).catch(err => err)
}

export default new Router({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})
